home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / amftp165 / rexx / receive.rexx < prev    next >
OS/2 REXX Batch file  |  1996-09-08  |  2KB  |  76 lines

  1. /*
  2.  
  3. AmFTP Rexx-Port Example Script, receive.rexx
  4.  
  5. Copyright © 1995-1996 by Mathias Mischler, All Rights Reserved.
  6.  
  7.  
  8. This easy example script connects to a host (ftp.vapor.com) and
  9. simply gets a file (AmFTP153.lzx) from a directory (support/amftp).
  10. Afterwards connection is closed and AmFTP quits.
  11.  
  12. This script was written to show the use of the AmFTP Rexx Port,
  13. because the is a major AmFTP-Rexx problem: AmFTP is a asyncronious
  14. program, so we _can't_ just start a command and than next one.
  15.  
  16. Solution: What we have to do, is to _initiate_ a command, wait until
  17. command is ready and than initiate next one (wait for this...).
  18.  
  19. AmFTP provides following functions to easy handle this:
  20.  
  21. INACTION:
  22. INACTION returns 0 when AmFTP is free to get new commands.
  23.          returns 1 when AmFTP is busy on working.
  24.  
  25. WAITACTION PORT:
  26. WAITACTION tells AmFTP to send a message to a specified MessagePort
  27. when it is ready with last command. So you can just do a WAITPKT.
  28. This example shows how to wait on such messages. We need to open
  29. rexxsupport.library to use 
  30. OPENPORT to create a MessagePort,
  31. CLOSEPORT to close a MessagePort and
  32. WAITPKT to wait for a message from AmFTP.
  33. (See also rexx.guide OPENPORT, CLOSEPORT, WAITPKT)
  34.  
  35. */
  36.  
  37. /* Open rexxsupport.library, and AMFTP Rexx-Port */
  38. OPTIONS RESULTS
  39. ADDLIB("rexxsupport.library",0,-30,0)
  40. RXLIB "AMFTP.1"
  41. ADDRESS 'AMFTP.1'
  42.  
  43. /* Create MessagePort */
  44. CALL OPENPORT("AMFTP-RESULT.1")
  45.  
  46. /* Change local directory */
  47. say "Change local directory..."
  48. CHANGELOCALDIR "ram:"
  49.  
  50. /* Connect to host */
  51. say "Connect..."
  52. CONNECTHOST "ftp.vapor.com"
  53. WAITACTION "AMFTP-RESULT.1"
  54. CALL WAITPKT "AMFTP-RESULT.1"
  55.  
  56. /* Change remote directory */
  57. say "Change remote directory..."
  58. CHANGEDIR "support/AmFTP"
  59. WAITACTION "AMFTP-RESULT.1"
  60. CALL WAITPKT "AMFTP-RESULT.1"
  61.  
  62. /* Receive a file */
  63. say "Receive AmFTP153.lha..."
  64. RECEIVE "AmFTP153.lha"
  65. WAITACTION "AMFTP-RESULT.1"
  66. CALL WAITPKT "AMFTP-RESULT.1"
  67.  
  68. /* Close Connection */
  69. CLOSE
  70.  
  71. /* Quit AmFTP */
  72. QUIT
  73.  
  74. /* Close our MessagePort */
  75. CALL CLOSEPORT "AMFTP-RESULT.1"
  76.